/**
 * @author kongolou (bilibili: 七秒Qimiao, tieba: 头发干衣服穿)
 * @date 2023-12-16
 * @brief 此脚本用于演示 [PE] 简化十炮 的 ch6+P1 阵解。
 * 
 * 阵名         [PE] 简化十炮
 * 阵解(双轨)   ch6+P1: I-PP | PP | I-PP | PP (1200 | 600 | 1200 | 600) + dd (3475)
 * 出场僵尸     <普僵>, <蹦极>, [白眼], [红眼], [小丑], [海豚], [潜水], [矿工], [冰车], [投篮], [舞王], [气球]
 * 出场植物     <寒冰菇>, <复制-寒冰菇>, <咖啡豆>, [睡莲], [毁灭菇], [樱桃炸弹]...
 * 
 * w1           PPSS 入轨, *尾炸炮用作同步炮同步炸九列*, 此后尾炸炮一恢复就炸后场, 直到 w9
 * w9           PP-N 脱轨, 通过核加速后触发本轮红眼投掷, 清场还需要三对炮, 可点冰压制, *注意此时不能使用尾炸炮*, 请留出尾炸炮
 * w10          PP-PP 入轨, *尾炸炮炸八列杀前场蹦极*, 此后尾炸炮一恢复就炸后场, 直到 w19
 * w19          I-PP-N 脱轨, 清场可点冰压制, *此时可使用尾炸炮*
 * w20          I-PP-PP 入轨(冰消珊瑚, 炮杀蹦极), *注意在结束前拖出尾炸炮和一个半的冰*, 以便下一轮选卡循环
 * 
 * 演示视频     【【植僵无尽】PE 简化十炮 ch6 键控翻新】 https://www.bilibili.com/video/BV1kw411j7nV/?share_source=copy_web&vd_source=b35357ac0ea0f85de9853e12d095f019
 */
#include <avz.h>

ACobManager gFrontCobManager;  // 前场炮组
ACobManager gBackCobManager;  // 尾炸炮组

void AScript()
{
    AAssumeWavelength({
        ATime(1, 601), ATime(2, 1200), ATime(3, 601), ATime(4, 1200),
        ATime(5, 601), ATime(6, 1200), ATime(7, 601), ATime(8, 1200),
        ATime(10, 601), ATime(11, 1200), ATime(12, 601), ATime(13, 1200),
        ATime(14, 601), ATime(15, 1200), ATime(16, 601), ATime(17, 1200),
        ATime(18, 601)
    });
    ASetZombies({
        APJ_0,  AWW_8, AQS_11, 
        ABC_12, AHT_14, AXC_15, 
        AQQ_16, AKG_17, ABJ_20,
        ATL_22, ABY_23, AHY_32 
    });
    ASelectCards({
        AICE_SHROOM, AM_ICE_SHROOM, 
        ACOFFEE_BEAN, ALILY_PAD, 
        ADOOM_SHROOM, ACHERRY_BOMB, 
        APUFF_SHROOM, ASUN_SHROOM, 
        ASCAREDY_SHROOM, AFLOWER_POT
    });
    AConnect(ATime(1, -599), [=] {
        gFrontCobManager.SetList({{3, 3}, {5, 5}, {3, 5}, {6, 5}, {4, 3}, {2, 5}, {4, 5}, {1, 5}});
        gBackCobManager.SetList({{3, 1}, {4, 1}});
        aIceFiller.Start({{3, 8}, {4, 8}});
    });
    // 加速波
    for (auto wave : {3, 5, 7, 12, 14, 16, 18}) {
        // 加速波开炮时机 = 舞王召唤 342cs - 炮落地时长 373cs
        AConnect(ATime(wave, 341 - 373), [=] {
            gFrontCobManager.Fire({{2, 9}, {5, 9}});
        });
        // 加速波尾炸时机 = 投掷小鬼时间 142cs - 炮落地时长 373cs
        AConnect(ATime(wave, 142 - 373), [=] {
            gBackCobManager.RecoverFire({{2, 2}, {5, 2}});
        });
    }
    // 减速波
    for (auto wave : {2, 4, 6, 8, 11, 13, 15, 17}) {
        // 减速波前 298cs 点预判冰
        AConnect(ATime(wave, -298 + 1), [=] {
            aIceFiller.Coffee();
        });
        // 减速波开炮时机 = 减速波波长 1200cs - 炮落地时长 373cs  - 刷新时间 200cs
        AConnect(ATime(wave, 1200 - 373 - 200), [=] {
            gFrontCobManager.Fire({{2, 9}, {5, 9}});
        });
        // 减速波尾炸时机 = 冰冻时间 400cs + 冰冻巨人投掷小鬼时间 284cs - 炮落地时长 373cs
        AConnect(ATime(wave, 400 + 284 - 373), [=] {
            gBackCobManager.RecoverFire({{2, 2}, {5, 2}});
        }); 
    }
    // w1
    AConnect(ATime(1, 341 - 373), [=] {
        gFrontCobManager.Fire({{2, 9}, {5, 9}});
        gBackCobManager.Fire({{2, 9}, {5, 9}});
    });
    // w9 请手动处理, 注意留出尾炸炮
    AConnect(ATime(9, 341 - 373), [=] {
        gFrontCobManager.Fire({{2, 9}, {5, 9}});
        ACard({ALILY_PAD, ADOOM_SHROOM, ACOFFEE_BEAN}, {{3, 9}, {4, 9}});
    });
    // w10
    AConnect(ATime(10, 341 - 373), [=] {
        gFrontCobManager.Fire({{2, 9}, {5, 9}});
    });
    // 炮杀蹦极时机 = 蹦极落地时长 394cs - 炮落地时长 373cs
    AConnect(ATime(10, 394 - 373), [=] {
        gBackCobManager.Fire({{2, 8}, {5, 8}});
    });
    // w19 请手动处理, 不必留尾炸炮
    AConnect(ATime(19, -298 + 1), [=] {
        aIceFiller.Coffee();
    });
    AConnect(ATime(19, 1200 - 373 - 200), [=] {
        gFrontCobManager.Fire({{2, 9}, {5, 9}});
    });
    // 点核时机 > 咖啡豆冷却 750cs - 点冰时机 298cs
    AConnect(ATime(19, 500), [=] {
        ACard({ALILY_PAD, ADOOM_SHROOM, ACOFFEE_BEAN}, {{3, 9}, {4, 9}});
    });
    // w20 请手动处理, 注意留出尾炸炮
    AConnect(ATime(20, -298 + 1), [=] {
        aIceFiller.Coffee();
    });
    AConnect(ATime(20, 1200 - 373 - 200), [=] {
        gFrontCobManager.Fire({{2, 9}, {5, 9}});
    });
    AConnect(ATime(20, 394 - 373), [=] {
        gFrontCobManager.Fire({{2, 8}, {5, 8}});
    });
    // 一键垫材
    AConnect('C', [=] {
        ACard({APUFF_SHROOM, ASUN_SHROOM, ASCAREDY_SHROOM, AFLOWER_POT}, {{1, 2}, {2, 2}, {5, 2}, {6, 2}});
    });
}
